<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/res/commons/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
  	<meta charset="utf-8">
  	<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  	<link rel="stylesheet" href="${path}/res/layui/css/layui.css"  media="all">
	<link rel="shortcut icon" href="${path}/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${path}/res/css/font.css">
    <link rel="stylesheet" href="${path}/res/css/xadmin.css">
    <script type="text/javascript" src="${path}/res/js/xadmin.js" charset="utf-8"></script>
    
    <script type="text/javascript" src="${path}/res/js/jquery-3.4.1.js"></script>
</head>  
<body  class="layui-fluid">
	<div class="x-body">
		<div class="layui-row">
	        <form class="layui-form layui-col-md12 x-so">
				<input class="layui-input" placeholder="上传开始日" name="starTime" id="start">
	          	<input class="layui-input" placeholder="上传截止日" name="endTime" id="end">
	          	<div class="layui-input-inline">
	            	<select name="pstatus">
	              		<option value="">全部商品</option>
	              		<option value="0">审核中</option>
	              		<option value="1">上架中</option>
	              		<option value="2">已下架</option>
	            	</select>
	          	</div>
	          	<input type="text" name="proTitle"  placeholder="请输入商品标题" autocomplete="off" class="layui-input">
	          	<button class="layui-btn"  lay-submit="" lay-filter="sreach" type="button"  id="query"><i class="layui-icon">&#xe615;</i></button>
		        <!-- <button class="layui-btn layui-btn-danger" onclick="delAll()" type="button"><i class="layui-icon"></i>批量删除</button> -->
		        <button class="layui-btn" onclick="x_admin_show('添加用户','${path}/product/productaddpage.jhtml')" type="button"><i class="layui-icon"></i>添加</button>
			</form>
			<table id="demo" lay-filter="test"></table>
		</div>
	</div>
	<script type="text/html" id="barDemo">
  		<a title="查看"  onclick="x_admin_show('编辑','order-view.html')" href="javascript:;"><i class="iconfont">&#xe6a2</i></a>
		<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;"><i class="iconfont">&#xe69d;</i></a>
		<a title="修改" onclick="member_del(this,'要删除的id')" href="javascript:;"><i class="iconfont">&#xe69e;</i></a>
	</script>

<script type="text/javascript" src="${path}/res/layui/layui.js" charset="utf-8"></script>
<script>
	layui.use('laydate', function(){
    	var laydate = layui.laydate;
	    laydate.render({
	      elem: '#start' //指定元素
	    });
	    laydate.render({
	      elem: '#end' //指定元素
	    });
	});
	var table;
	layui.use('table', function(){
        table = layui.table;
        
		table.render({
			elem: '#demo'
		    ,height: 'full'
		    ,url: '${path}/product/getProductlist.jhtml' //数据接口
		    ,limits:[15,20,25,30]
		    ,limit:15	
		    ,cols: [[ //表头
				{type:'checkbox'}
		      	,{field: 'proId', title: 'ID', width:60 }
		      	,{field: 'proTitle', title: '商品标题', width:380 }
		      	,{field:'proStatus', title:'商品状态', width:90,align:'center',templet:function(d){
		      			if(d.proStatus == 0){
		      				return '<span style="color:#393D49">审核中</span>'
		      			}else if(d.proStatus == 1){
		      				return '<span style="color:#FF5722">上架中</span>'
		      			}else if(d.proStatus == 2){
		      				return '<span style="color:#5FB878">已下架</span>'
		      			}
			     }}
		      	,{field:'proPrice', title:'商品原价', width:100,align:'center',sort:true}
		      	,{field:'proDiscountPrice', title:'商品售价',width:100,align:'center',sort:true}
		      	,{field:'proSellNum', title:'已售数量', width:100,align:'center',sort:true}
		      	,{field:'proColor', title:'颜色', width:200}
		      	,{field:'proSize', title:'尺码', width:150}
		      	,{field:'createdTime', title:'上传时间', width:180, sort: true,templet:function(d){
		      		return new Date(parseInt(d.createdTime)).toLocaleString().replace(/:\d{1,2}$/,' ');   
			     }}
		      	,{field:'bannerDesc', title:'按钮描述', width:150}
		      	,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
			]]
		    ,page: true//开启分页
		});
		$('.layui-row .layui-btn').on('click', function(){
			table.reload('demo', {
				url: '${path}/product/getProductlist.jhtml'
			  	,where: {
			  		starTime:$("input[name='starTime'] ").val(),
			  		endTime:$("input[name='endTime'] ").val(),
			  		pstatus:$("select[name='pstatus'] ").val(),
			  		proTitle:$("input[name='proTitle'] ").val()
				} 
			});
		});
	});
</script>
</body>
</html>